package com.axzhengxin.platform.statistics.service.impl;

import com.axzhengxin.platform.business.domain.BizApplyInfo;
import com.axzhengxin.platform.financeProduct.mapper.FspFinanceProductMapper;
import com.axzhengxin.platform.statistics.domain.ProductSearch;
import com.axzhengxin.platform.statistics.domain.ProvinceStatistics;
import com.axzhengxin.platform.statistics.mapper.ProvinceStatisticsMapper;
import com.axzhengxin.platform.statistics.service.ProvinceStatisticsService;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.utils.DictUtils;
import com.ruoyi.common.utils.SecurityUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.*;

/**
 * @author AHZJ0005
 */
@Slf4j
@Service
public class ProvinceStatisticsServiceImpl implements ProvinceStatisticsService {
    @Autowired
    private ProvinceStatisticsMapper statisticsMapper;
    @Autowired
    private FspFinanceProductMapper fspFinanceProductMapper;

    @Override
    @DataScope(deptAlias = "su")
    public List<ProvinceStatistics> productStatistics(ProductSearch productSearch) {
        //产品统计
        List<ProvinceStatistics> productStatistics = statisticsMapper.productStatistics(productSearch);
        return productStatistics;
    }

    @Override
    @DataScope(deptAlias = "t")
    public List<ProvinceStatistics> productStatisticsGuaranteeType(ProductSearch productSearch) {
        //产品统计
        if (SecurityUtils.isAdmin(SecurityUtils.getLoginUser().getUser().getUserId())){
            productSearch.setIsAdmin(0);
        }else {
            productSearch.setIsAdmin(1);
        }

        List<ProvinceStatistics> productStatistics = statisticsMapper.productStatisticsGuaranteeType(productSearch);
        return productStatistics;
    }

    @Override
    public List<ProvinceStatistics> productStatisticsByProduct(ProductSearch productSearch) {
        return statisticsMapper.productStatisticsByProduct(productSearch);
    }

    @Override
    public List<ProvinceStatistics> productStatisticsByDept(ProductSearch productSearch) {
        return statisticsMapper.productStatisticsByDept(productSearch);
    }

    @Override
    @DataScope(deptAlias = "su",userAlias = "su")
    public List<ProvinceStatistics> getNumericalStatementByArea(ProductSearch productSearch) {
        return statisticsMapper.getNumericalStatementByArea(productSearch);
    }

    @Override
    @DataScope(deptAlias = "su",userAlias = "su")
    public List<ProvinceStatistics> getNumericalStatementByAreaMonth(ProductSearch productSearch) {
        return statisticsMapper.getNumericalStatementByAreaMonth(productSearch);
    }

    @Override
    public List<ProvinceStatistics> getNumericalStatementByDept(ProductSearch productSearch) {
        return statisticsMapper.getNumericalStatementByDept(productSearch);
    }

    @Override
    public List<ProvinceStatistics> getNumericalStatementByDeptYearAndMonth(ProductSearch productSearch) {
        return statisticsMapper.getNumericalStatementByDeptYearAndMonth(productSearch);
    }

    @Override
    @DataScope(deptAlias = "sd",userAlias = "su")
    public List<ProvinceStatistics> getNumericalStatementByCustomer(ProductSearch productSearch) {
        return statisticsMapper.getNumericalStatementByCustomer(productSearch);
    }

    @Override
    public Integer getAncLength(Long deptId) {
        return statisticsMapper.getAncLength(deptId);
    }


}
